// pages/interests-rule/interests-rule.js
"use strict"
import mode from "../../utils/mode.js";
const wxParse = require('../../wxParse/wxParse.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        rules:'',   //富文本展示规则
        activeNames: ['1'],
        level: [
            { icon: '../../image/icon/level@2x.png', level: '银钻等级' },
            { icon: '../../image/icon/level@2x.png', level: '金钻等级' },
            { icon: '../../image/icon/level@2x.png', level: '黑钻等级' }
        ],
        
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
    },
    getData(){
        let that = this
        wx.$api.getScoreRuleInfo().then(res=>{
                if(res.code==1){
                    let data = res.data
                    that.setData({
                        rules:data.article_content
                    })
                }
        })
    },
    onChange(event) {
        this.setData({
            activeNames: event.detail,
        });
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        this.getData()
        this.getProblem()
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },
    getProblem(){
        let that = this;
        mode.getProblem().then(
            item=>{
                var resArray = item.data
                    for (let i = 0; i < resArray.length; i++) {
                        wxParse.wxParse('content' + i, 'html', resArray[i].article_content, that,5);
                        if (i === resArray.length - 1) {
                            wxParse.wxParseTemArray("wxParseListArr",'content', resArray.length, that,5)
                        }
                        resArray[i].article_title = resArray[i].article_title.replace(/&gt;/ ,">")
                    }
                    that.setData({
                        questionList:resArray
                    })
            }
        )
    },
    toTiaoKuan(){
        wx.navigateTo({
          url: '../police/police',
        })
    }
})